package com.poker.ui;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;

import com.poker.R;

/**
 * 自定义的按钮
 * 
 * @author samoin
 * @since 2011-06-28
 * 
 */
public class MyButton extends Button {
	public MyButton(Context context) {
		super(context);
	}

	public MyButton(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public MyButton(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		if (event.getAction() == MotionEvent.ACTION_DOWN) {
			this.setBackgroundResource(R.drawable.btn_bg2);
			Log.i("TestAndroid Button", "MotionEvent.ACTION_DOWN");
		} else if (event.getAction() == MotionEvent.ACTION_UP) {
			this.setBackgroundResource(R.drawable.btn_bg1);
			Log.i("TestAndroid Button", "MotionEvent.ACTION_UP");
		}
		return super.onTouchEvent(event);
	}

	/**
	 * 显示
	 */
	public void show() {
		this.setVisibility(View.VISIBLE);
	}

	/**
	 * 隐藏，不占位
	 */
	public void hideWithGone() {
		this.setVisibility(View.GONE);
	}

	/**
	 * 隐藏，占位
	 */
	public void hide() {
		this.setVisibility(View.INVISIBLE);
	}
}
